﻿using System;
using System.ComponentModel;

namespace HalconDotNet
{
	/// <summary>Represents an instance of a scattered data interpolator.</summary>
	// Token: 0x0200005D RID: 93
	public class HScatteredDataInterpolator : HHandle
	{
		// Token: 0x0600173D RID: 5949 RVA: 0x0000883B File Offset: 0x00006A3B
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HScatteredDataInterpolator() : base(HHandleBase.UNDEF)
		{
		}

		// Token: 0x0600173E RID: 5950 RVA: 0x00095774 File Offset: 0x00093974
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HScatteredDataInterpolator(IntPtr handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x0600173F RID: 5951 RVA: 0x00095783 File Offset: 0x00093983
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HScatteredDataInterpolator(HHandle handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x06001740 RID: 5952 RVA: 0x00095792 File Offset: 0x00093992
		private void AssertSemType()
		{
			base.AssertSemType("scattered_data_interpolator");
		}

		// Token: 0x06001741 RID: 5953 RVA: 0x0009579F File Offset: 0x0009399F
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HScatteredDataInterpolator obj)
		{
			obj = new HScatteredDataInterpolator(HHandleBase.UNDEF);
			return obj.Load(proc, parIndex, err);
		}

		// Token: 0x06001742 RID: 5954 RVA: 0x000957B8 File Offset: 0x000939B8
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HScatteredDataInterpolator[] obj)
		{
			HTuple htuple;
			err = HTuple.LoadNew(proc, parIndex, err, out htuple);
			obj = new HScatteredDataInterpolator[htuple.Length];
			for (int i = 0; i < htuple.Length; i++)
			{
				obj[i] = new HScatteredDataInterpolator(HalconAPI.IsLegacyHandleMode() ? htuple[i].IP : htuple[i].H);
			}
			htuple.Dispose();
			return err;
		}

		/// <summary>
		///   Creates an interpolator for the interpolation of scattered data.
		///   Modified instance represents: Handle of the scattered data interpolator
		/// </summary>
		/// <param name="method">Method for the interpolation Default: "thin_plate_splines"</param>
		/// <param name="rows">Row coordinates of the points used  for the interpolation</param>
		/// <param name="columns">Column coordinates of the points used  for the interpolation</param>
		/// <param name="values">Values of the points used  for the interpolation</param>
		/// <param name="genParamName">Names of the generic parameters  that can be adjusted Default: []</param>
		/// <param name="genParamValue">Values of the generic parameters that can be adjusted Default: []</param>
		// Token: 0x06001743 RID: 5955 RVA: 0x00095828 File Offset: 0x00093A28
		public HScatteredDataInterpolator(string method, HTuple rows, HTuple columns, HTuple values, HTuple genParamName, HTuple genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(292);
			HalconAPI.StoreS(proc, 0, method);
			HalconAPI.Store(proc, 1, rows);
			HalconAPI.Store(proc, 2, columns);
			HalconAPI.Store(proc, 3, values);
			HalconAPI.Store(proc, 4, genParamName);
			HalconAPI.Store(proc, 5, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(rows);
			HalconAPI.UnpinTuple(columns);
			HalconAPI.UnpinTuple(values);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>Clear a scattered data interpolator.</summary>
		/// <param name="scatteredDataInterpolatorHandle">Handle of the scattered data interpolator</param>
		// Token: 0x06001744 RID: 5956 RVA: 0x000958C0 File Offset: 0x00093AC0
		public static void ClearScatteredDataInterpolator(HScatteredDataInterpolator[] scatteredDataInterpolatorHandle)
		{
			HTuple htuple = HHandleBase.ConcatArray(scatteredDataInterpolatorHandle);
			IntPtr proc = HalconAPI.PreCall(290);
			HalconAPI.Store(proc, 0, htuple);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(htuple);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(scatteredDataInterpolatorHandle);
		}

		/// <summary>
		///   Clear a scattered data interpolator.
		///   Instance represents: Handle of the scattered data interpolator
		/// </summary>
		// Token: 0x06001745 RID: 5957 RVA: 0x00095904 File Offset: 0x00093B04
		public void ClearScatteredDataInterpolator()
		{
			IntPtr proc = HalconAPI.PreCall(290);
			base.Store(proc, 0);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Interpolation of scattered data using a scattered data interpolator.
		///   Instance represents: Handle of the scattered data interpolator
		/// </summary>
		/// <param name="row">Row coordinates of points  to be interpolated</param>
		/// <param name="column">Column coordinates of points  to be interpolated</param>
		/// <returns>Values of interpolated points</returns>
		// Token: 0x06001746 RID: 5958 RVA: 0x00095938 File Offset: 0x00093B38
		public HTuple InterpolateScatteredData(HTuple row, HTuple column)
		{
			IntPtr proc = HalconAPI.PreCall(291);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, row);
			HalconAPI.Store(proc, 2, column);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(row);
			HalconAPI.UnpinTuple(column);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Interpolation of scattered data using a scattered data interpolator.
		///   Instance represents: Handle of the scattered data interpolator
		/// </summary>
		/// <param name="row">Row coordinates of points  to be interpolated</param>
		/// <param name="column">Column coordinates of points  to be interpolated</param>
		/// <returns>Values of interpolated points</returns>
		// Token: 0x06001747 RID: 5959 RVA: 0x0009599C File Offset: 0x00093B9C
		public double InterpolateScatteredData(double row, double column)
		{
			IntPtr proc = HalconAPI.PreCall(291);
			base.Store(proc, 0);
			HalconAPI.StoreD(proc, 1, row);
			HalconAPI.StoreD(proc, 2, column);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			double result;
			num = HalconAPI.LoadD(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Creates an interpolator for the interpolation of scattered data.
		///   Modified instance represents: Handle of the scattered data interpolator
		/// </summary>
		/// <param name="method">Method for the interpolation Default: "thin_plate_splines"</param>
		/// <param name="rows">Row coordinates of the points used  for the interpolation</param>
		/// <param name="columns">Column coordinates of the points used  for the interpolation</param>
		/// <param name="values">Values of the points used  for the interpolation</param>
		/// <param name="genParamName">Names of the generic parameters  that can be adjusted Default: []</param>
		/// <param name="genParamValue">Values of the generic parameters that can be adjusted Default: []</param>
		// Token: 0x06001748 RID: 5960 RVA: 0x000959F4 File Offset: 0x00093BF4
		public void CreateScatteredDataInterpolator(string method, HTuple rows, HTuple columns, HTuple values, HTuple genParamName, HTuple genParamValue)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(292);
			HalconAPI.StoreS(proc, 0, method);
			HalconAPI.Store(proc, 1, rows);
			HalconAPI.Store(proc, 2, columns);
			HalconAPI.Store(proc, 3, values);
			HalconAPI.Store(proc, 4, genParamName);
			HalconAPI.Store(proc, 5, genParamValue);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(rows);
			HalconAPI.UnpinTuple(columns);
			HalconAPI.UnpinTuple(values);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}
	}
}
